<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<div style="padding:10px;">
<form id="form-add">
  <div class="form-group">
    <label for="exampleInputEmail1">姓名</label>
    <input type="text" class="form-control" name="emp_name" id="empName" placeholder="请输入姓名">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">月薪</label>
    <input type="text" class="form-control" name="emp_salary" id="empSal" placeholder="请输入月薪">
  </div>
  <div class="form-group">
    <label for="exampleInputEmail1">时间</label>
    <input type="date" class="form-control" name="emp_date" id="empDate">
  </div>
  
  <button type="button" class="btn btn-info" id="bn-add">添加</button>
  <button type="button" onclick="layer.close(layIdx);" class="btn btn-info">取消</button>
</form>
</div>
<script>
	
	$('#bn-add').click(function(){
		$.ajax({
			url:'empServlet?operate=insertEmp',
			method:'post',
			data:$('#form-add').serialize(),
			dataType:"json"
		}).done(function(data){
			if(data.msg=="success"){
				
				layer.close(layIdx);
				loadEmpInfo();
				swal({
					  title: data.msg,
					  icon: "success",
					  button: "确定"
				});
				/* swal({ 
				  title: "添加成功", 
				  text: "2秒后自动关闭。", 
				  timer: 2000, 
				  showConfirmButton: false 
				});  */
			}
		});
	});
</script>
